package model

import (
	"github.com/google/uuid"
	"gorm.io/gorm"
)

type User struct {
	Id        string `json:"id" gorm:"primaryKey;type:varchar(36);column:id;"`
	UserName  string `json:"username" gorm:"type:varchar(255);column:username;uniqueIndex;not null;"`
	Password  string `json:"password" gorm:"type:varchar(255);column:password;not null;"`
	Email     string `json:"email" gorm:"type:varchar(255);column:email;uniqueIndex;not null;"`
	CreatedAt int64  `json:"created_at" gorm:"type:bigint;column:created_at;not null;"`
}

func (User) TableName() string {
	return "user"
}

func (u *User) BeforeCreate(tx *gorm.DB) (err error) {
	u.Id = uuid.NewString()
	return
}
